package com.gitee.feizns.explore.data_structure.linked_list.singly.odd;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author feizns
 * @since 2019/9/29
 */
public class ListNode {

    int val;
    ListNode next;

    ListNode(int x) {
        val = x;
        next = null;
    }

    public void print() {
        System.out.println(getEle(this).map(Object::toString).collect(Collectors.joining(",")));
    }

    public static Stream<Object> getEle(ListNode node) {
        Stream.Builder<Object> builder = Stream.builder();
        while ( node != null ) {
            builder.add(node.val);
            node = node.next;
        }
        return builder.build();
    }

}
